package com.learn.eventbus;

import java.lang.reflect.Constructor;

/**
 * 编译时生成MainActivity$$ViewBind.java文件，生成目录在
 * app/build/generated/source/apt/debug/com.learn.eventbus.MainActivity$$ViewBind.java
 *
 * package com.learn.eventbus;
 * import android.view.View;
 * public class MainActivity$$ViewBind {
 *     public MainActivity$$ViewBind(final com.learn.eventbus.MainActivity target) {
 *         target.btn_write = target.findViewById(2131165250);
 *         target.btn_read = target.findViewById(2131165249);
 *     }
 * }
 */
public class ButterKnife {

    public static void bind(Object activity) {
        Class<?> aClass = activity.getClass();
        String bindName = aClass.getName() + "$$ViewBind";
        try {
            Class<?> bindClazz = Class.forName(bindName);
            Constructor<?> constructor = bindClazz.getConstructor(activity.getClass());
            constructor.newInstance(activity);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
